package ddd.ajava.chapter4.question2;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test {

	private static List<Person> persons = new ArrayList<Person>();

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int menuType = 0;
		boolean flag = true;
		while (flag) {
			menu();
			menuType = scanner.nextInt();
			switch (menuType) {
			case 1:
				input();
				break;
			case 2:
				output();
				break;
			default:
				flag = false;
			}
		}

	}

	public static void menu() {
		System.out.println("请选择操作：录入请输入1，输出请输入2，退出请输入3");
	}

	private static void input() {
		PersonInput personInput = new PersonInput();
		Person person = new Person();
		person = personInput.process(person);
		persons.add(person);
		System.out.println("录入成功");
	}

	private static void output() {
		PersonDisplay display = new PersonDisplay();
		for (Person person : persons) {
			display.process(person);
		}
		if (persons.size() <= 0) {
			System.out.println("数据为空.");
		}
	}

}
